/* $RCSFile: PageRequestHandler.cs $
 * Apache license v2 2011 by Christian Surieux
 * $Source: ?/ADNCRM.Core/PageRequestHandler.cs $
 * $log$
 * Revision 6 2010/08/06 19:56:27  christian.surieux
 *   Added Log to All cs files
 */

using System;
using System.Data;
using System.Diagnostics;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Globalization;

using AddonNice.Security;
using AddonNice.Diagnostics;

/// <summary>
/// Event and delegate implemented for page request
/// </summary>
namespace AddonNice.Core
{
    // Monitor page requests
    public class PageRequestEventArgs : MonitorEventArgs
    {

        public PageRequestEventArgs(Guid UID,string userName, int typeCode,Guid CRMUID, int PID, int TbID,string userData,bool underCRM,bool isCallBk)
            : base(MonLogType.PageRequest,UID,userName,typeCode,CRMUID,PID, TbID, "PageRequest", userData,underCRM,isCallBk)
        {
            if ( MonitoringTrace.Sw.TraceVerbose )
                Trace.WriteLine( string.Format(CultureInfo.InvariantCulture,"[V]PageRequestEventArgs Ctor UID: {0}, CRMID: {1}, PID: {2}, pgID: {3}", new object[]{UID,CRMUID,PID,TbID}),MonitoringTrace.Sw.Info);
			}

        public PageRequestEventArgs(MonLogType ltp,Guid UID,string userName, int typeCode,Guid CRMUID, int PID, int TbID,string action,string userData,bool underCRM,bool isCallBk)
            : base(ltp,UID,userName,typeCode,CRMUID,PID, TbID,action, userData,underCRM,isCallBk)
        {
            if ( MonitoringTrace.Sw.TraceVerbose )
                Trace.WriteLine( string.Format(CultureInfo.InvariantCulture,"[V]PageRequestEventArgs Ctor UID: {0}, CRMID: {1}, PID: {2}, pgID: {3}", new object[]{UID,CRMUID,PID,TbID}),MonitoringTrace.Sw.Info);
			}
    }
    public delegate void PageRequestEventHandler(MonitorEventArgs e);

    // Monitor items requests
    public class ItemRequestEventArgs : MonitorEventArgs
    {

        public ItemRequestEventArgs(Guid UID,string userName,int typeCode,Guid CRMUID,int PID,int TbID,int MdID,int itmID,string userData,bool underCRM,bool isCallBk)
            : base(MonLogType.ItemView,UID,userName,typeCode,CRMUID,PID, TbID,MdID,itmID,Guid.Empty,"ItemRequest", userData,underCRM,isCallBk)
        {
            if ( MonitoringTrace.Sw.TraceVerbose )
                Trace.WriteLine( string.Format(CultureInfo.InvariantCulture,"[V]ItemRequestEventArgs Ctor UID: {0}, CRMID: {1}, PID: {2}, pgID: {3}, mdID: {4}, itmID: {5}", new object[]{UID,CRMUID,PID,TbID,MdID,itmID}),MonitoringTrace.Sw.Info);
			}
        public ItemRequestEventArgs(MonLogType ltp,Guid UID,string userName,int typeCode,Guid CRMUID,int PID,int TbID,int MdID,int itmID,string userData,bool underCRM,bool isCallBk)
            : base(ltp,UID,userName,typeCode,CRMUID,PID, TbID,MdID,itmID,Guid.Empty,"ItemRequest", userData,underCRM,isCallBk)
        {
            if ( MonitoringTrace.Sw.TraceVerbose )
                Trace.WriteLine( string.Format(CultureInfo.InvariantCulture,"[V]ItemRequestEventArgs Ctor UID: {0}, CRMID: {1}, PID: {2}, pgID: {3}, mdID: {4}, itmID: {5}", new object[]{UID,CRMUID,PID,TbID,MdID,itmID}),MonitoringTrace.Sw.Info);
			}
    }
    public delegate void ItemRequestEventHandler(MonitorEventArgs e);

    // Monitor CRM items requests
    public class CrmItemRequestEventArgs : MonitorEventArgs
    {
        /// <summary>
        /// We use ItemID to contain the CrmItem typecode, userData containe the logged user name
        /// </summary>
        public CrmItemRequestEventArgs(Guid UID,string userName,int typeCode,Guid CRMUID,int PID,int TbID,int MdID,int CrmItmTypeCode,Guid CrmItmID,string action,string userData,bool underCRM,bool isCallBk)
            : base(MonLogType.CrmItemView,UID,userName,typeCode,CRMUID,PID, TbID,MdID,CrmItmTypeCode,CrmItmID,action, userData,underCRM,isCallBk)
        {
            if ( MonitoringTrace.Sw.TraceVerbose )
                Trace.WriteLine( string.Format(CultureInfo.InvariantCulture,"[V]CrmItemRequestEventArgs Ctor UID: {0}, CRMID: {1}, PID: {2}, pgID: {3}, mdID: {4}, CrmItmTypeCode: {5}, CrmItmID: {6}, Action: {7}", 
                    new object[]{UID,CRMUID,PID,TbID,MdID,CrmItmTypeCode,CrmItmID,action}),MonitoringTrace.Sw.Info);
			}
        public CrmItemRequestEventArgs(MonLogType ltp,Guid UID,string userName,int typeCode,Guid CRMUID,int PID,int TbID,int MdID,int CrmItmTypeCode,Guid CrmItmID,string action,string userData,bool underCRM,bool isCallBk)
            : base(ltp,UID,userName,typeCode,CRMUID,PID, TbID,MdID,CrmItmTypeCode,CrmItmID,action, userData,underCRM,isCallBk)
        {
            if ( MonitoringTrace.Sw.TraceVerbose )
                Trace.WriteLine( string.Format(CultureInfo.InvariantCulture,"[V]CrmItemRequestEventArgs Ctor UID: {0}, CRMID: {1}, PID: {2}, pgID: {3}, mdID: {4}, CrmItmTypeCode: {5}, CrmItmID: {6}, Action: {7}", 
                    new object[]{UID,CRMUID,PID,TbID,MdID,CrmItmTypeCode,CrmItmID,action}),MonitoringTrace.Sw.Info);
			}
    }

    public delegate void CrmItemRequestEventHandler(MonitorEventArgs e);
}
